package com.zxcz.controller;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.zxcz.domain.PageResult;
import com.zxcz.domain.Resource;
import com.zxcz.domain.Result;
import com.zxcz.service.ResourceService;

@RestController
@RequestMapping(value = "/resource")
public class ResourceController {
	@Autowired
	private ResourceService resourceService;
	private static final Log logger = LogFactory.getLog(ResourceController.class);
	
	/**
	 * 分页
	 */
	@RequestMapping("/fingPage")
	public PageResult<Resource> queryPage(int pageNum,int pageSize, String name, String startTime, String endTime, String account) {
		return resourceService.queryPage(pageNum, pageSize, name, startTime, endTime, account);
	}
	
	/**
	 * 分页获取对应用户的资源
	 * @return
	 */
	@RequestMapping("/userResource")
	public PageResult userResourcePage(int pageNum,int pageSize, String name, String startTime, String endTime) {
		return resourceService.userResourcePage(pageNum, pageSize, name, startTime, endTime);
	}
	
	/**
	 * 添加资源
	 */
	@RequestMapping("/insert")
	public Result<Object> insertResource(Resource resource) {
		return resourceService.insertResource(resource);
	}
	
	/**
	 * 修改资源
	 */
	@RequestMapping("/update")
	public Result<Object> updateResource(Resource resource) {
		return resourceService.updateResource(resource);
	}
}
